package com.material.factory.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.material.common.utils.bean.BeanUtil;
import com.material.factory.domain.FactoryFuel;
import com.material.factory.domain.FactoryInfo;
import com.material.factory.mapper.FactoryFuelMapper;
import com.material.factory.mapper.FactoryInfoMapper;
import com.material.factory.vo.FactoryFuelAttributeVo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.material.factory.mapper.FactoryFuelAttributeMapper;
import com.material.factory.domain.FactoryFuelAttribute;
import com.material.factory.service.IFactoryFuelAttributeService;

/**
 * 燃料品名指标化验属性Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@Service
public class FactoryFuelAttributeServiceImpl implements IFactoryFuelAttributeService 
{
    @Autowired
    private FactoryFuelAttributeMapper factoryFuelAttributeMapper;
    @Autowired
    private FactoryFuelMapper factoryFuelMapper;
    @Autowired
    private FactoryInfoMapper factoryInfoMapper;

    /**
     * 查询燃料品名指标化验属性
     * 
     * @param id 燃料品名指标化验属性主键
     * @return 燃料品名指标化验属性
     */
    @Override
    public FactoryFuelAttribute selectFactoryFuelAttributeById(Long id)
    {
        return factoryFuelAttributeMapper.selectFactoryFuelAttributeById(id);
    }

    /**
     * 查询燃料品名指标化验属性列表
     * 
     * @param factoryFuelAttribute 燃料品名指标化验属性
     * @return 燃料品名指标化验属性
     */
    @Override
    public List<FactoryFuelAttribute> selectFactoryFuelAttributeList(FactoryFuelAttribute factoryFuelAttribute)
    {
        return factoryFuelAttributeMapper.selectFactoryFuelAttributeList(factoryFuelAttribute);
    }

    /**
     * 新增燃料品名指标化验属性
     * 
     * @param factoryFuelAttribute 燃料品名指标化验属性
     * @return 结果
     */
    @Override
    public int insertFactoryFuelAttribute(FactoryFuelAttribute factoryFuelAttribute)
    {
        return factoryFuelAttributeMapper.insertFactoryFuelAttribute(factoryFuelAttribute);
    }

    /**
     * 修改燃料品名指标化验属性
     * 
     * @param factoryFuelAttribute 燃料品名指标化验属性
     * @return 结果
     */
    @Override
    public int updateFactoryFuelAttribute(FactoryFuelAttribute factoryFuelAttribute)
    {
        return factoryFuelAttributeMapper.updateFactoryFuelAttribute(factoryFuelAttribute);
    }

    /**
     * 批量删除燃料品名指标化验属性
     * 
     * @param ids 需要删除的燃料品名指标化验属性主键
     * @return 结果
     */
    @Override
    public int deleteFactoryFuelAttributeByIds(Long[] ids)
    {
        return factoryFuelAttributeMapper.deleteFactoryFuelAttributeByIds(ids);
    }

    /**
     * 删除燃料品名指标化验属性信息
     * 
     * @param id 燃料品名指标化验属性主键
     * @return 结果
     */
    @Override
    public int deleteFactoryFuelAttributeById(Long id)
    {
        return factoryFuelAttributeMapper.deleteFactoryFuelAttributeById(id);
    }

    @Override
    public List<FactoryFuelAttributeVo> selectFactoryFuelAttributePageList(FactoryFuelAttribute factoryFuelAttribute) {
        //List<FactoryFuelAttribute> factoryFuelAttributes = factoryFuelAttributeMapper.selectFactoryFuelAttributeList(factoryFuelAttribute);

        List<FactoryFuelAttributeVo> factoryFuelAttributeVos = factoryFuelAttributeMapper.selectFactoryFuelAttributePageList(factoryFuelAttribute);

//        Long fuelId = factoryFuelAttributes.get(0).getFuelId();
//        Long factoryId = factoryFuelAttributes.get(0).getFactoryId();
//        FactoryFuel factoryFuel = factoryFuelMapper.selectFactoryFuelById(fuelId);
//        FactoryInfo factoryInfo = factoryInfoMapper.selectFactoryInfoById(factoryId);
//        List<FactoryFuelAttributeVo> factoryFuelAttributeVos = BeanUtil.copyProperties(factoryFuelAttributes, FactoryFuelAttributeVo.class);
//        factoryFuelAttributeVos.forEach(f->{
//            f.setFuelName(factoryFuel.getName());
//            f.setFactoryName(factoryInfo.getName());
//        });
        return factoryFuelAttributeVos;
    }
}
